USE [HelpUs]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_premiopagamento]') AND parent_object_id = OBJECT_ID(N'[dbo].[pagamentoSets]'))
ALTER TABLE [dbo].[pagamentoSets] DROP CONSTRAINT [FK_premiopagamento]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_resolProblemapagamento]') AND parent_object_id = OBJECT_ID(N'[dbo].[pagamentoSets]'))
ALTER TABLE [dbo].[pagamentoSets] DROP CONSTRAINT [FK_resolProblemapagamento]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuOrganizacaopagamento]') AND parent_object_id = OBJECT_ID(N'[dbo].[pagamentoSets]'))
ALTER TABLE [dbo].[pagamentoSets] DROP CONSTRAINT [FK_usuOrganizacaopagamento]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuResolvedorSetspagamento]') AND parent_object_id = OBJECT_ID(N'[dbo].[pagamentoSets]'))
ALTER TABLE [dbo].[pagamentoSets] DROP CONSTRAINT [FK_usuResolvedorSetspagamento]
GO

USE [HelpUs]
GO

/****** Object:  Table [dbo].[pagamentoSets]    Script Date: 05/21/2012 22:41:50 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pagamentoSets]') AND type in (N'U'))
DROP TABLE [dbo].[pagamentoSets]
GO

USE [HelpUs]
GO

/****** Object:  Table [dbo].[pagamentoSets]    Script Date: 05/21/2012 22:41:50 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[pagamentoSets](
	[idPagamento] [int] IDENTITY(1,1) NOT NULL,
	[formaPag] [nvarchar](4) NOT NULL,
	[resolProblema_idResolvProb] [int] NOT NULL,
	[usuOrganizacao_idOrg] [int] NOT NULL,
	[usuResolvedorSets_idUsuRes] [int] NOT NULL,
	[premio_idPremio] [int] NOT NULL,
 CONSTRAINT [PK_pagamentoSets] PRIMARY KEY CLUSTERED 
(
	[idPagamento] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[pagamentoSets]  WITH CHECK ADD  CONSTRAINT [FK_premiopagamento] FOREIGN KEY([premio_idPremio])
REFERENCES [dbo].[premioSets] ([idPremio])
GO

ALTER TABLE [dbo].[pagamentoSets] CHECK CONSTRAINT [FK_premiopagamento]
GO

ALTER TABLE [dbo].[pagamentoSets]  WITH CHECK ADD  CONSTRAINT [FK_resolProblemapagamento] FOREIGN KEY([resolProblema_idResolvProb])
REFERENCES [dbo].[resolProblemaSets] ([idResolvProb])
GO

ALTER TABLE [dbo].[pagamentoSets] CHECK CONSTRAINT [FK_resolProblemapagamento]
GO

ALTER TABLE [dbo].[pagamentoSets]  WITH CHECK ADD  CONSTRAINT [FK_usuOrganizacaopagamento] FOREIGN KEY([usuOrganizacao_idOrg])
REFERENCES [dbo].[enderecoSet_usuOrganizacao] ([idOrg])
GO

ALTER TABLE [dbo].[pagamentoSets] CHECK CONSTRAINT [FK_usuOrganizacaopagamento]
GO

ALTER TABLE [dbo].[pagamentoSets]  WITH CHECK ADD  CONSTRAINT [FK_usuResolvedorSetspagamento] FOREIGN KEY([usuResolvedorSets_idUsuRes])
REFERENCES [dbo].[usuResolvedorSets] ([idUsuRes])
GO

ALTER TABLE [dbo].[pagamentoSets] CHECK CONSTRAINT [FK_usuResolvedorSetspagamento]
GO


